Imports CapaDeDatos
Imports System.Data.SqlClient

Public Class nAsignacionesDeRemitos
    Private AsignacionesDeRemitos As dAsignacionesDeRemitos = New dAsignacionesDeRemitos()
    Private Personal As CapaDeNegocios.nPersonal = New CapaDeNegocios.nPersonal
    Private TipoTalonario As CapaDeNegocios.nTipoTalonario = New CapaDeNegocios.nTipoTalonario
    Private Talonario As CapaDeNegocios.nTalonario = New CapaDeNegocios.nTalonario
    Public Function Eliminar(ByVal idAsignacionesDeRemitos As String, ByVal idTalonario As String) As Boolean
        '        If idTalonario <> "" And AsignacionesDeRemitos.Eliminar(idAsignacionesDeRemitos) Then
        If idTalonario <> "" And AsignacionesDeRemitos.Modificar(idAsignacionesDeRemitos, "", Now.Date.ToShortDateString(), idTalonario, "") Then
            Return Talonario.Modificar(idTalonario, "", "", "", 3, "")
        Else
            Return False
        End If
    End Function

    Public Function Insertar(ByVal IdTalonario As String, ByVal Legajo As String) As Boolean
        If AsignacionesDeRemitos.Insertar(IdTalonario, Legajo) Then
            Return Talonario.Modificar(IdTalonario, "", "", "", 1, "")
        Else
            Return False
        End If
    End Function
    Public Function BuscarFiltrado(ByVal idAsignacionesDeRemitos As String, ByVal FechaDeAlta As String, ByVal FechaDeBaja As String, ByVal IdTalonario As String, ByVal Legajo As String) As DataSet
        Dim dts As DataSet
        dts = AsignacionesDeRemitos.BuscarFiltrado(idAsignacionesDeRemitos, FechaDeAlta, FechaDeBaja, IdTalonario, Legajo)
        dts.Tables(0).Columns.Add("IdTipoTalonario")
        dts.Tables(0).Columns.Add("Talonario")
        dts.Tables(0).Columns.Add("Operador")
        dts.Tables(0).Columns.Add("Rango")
        Dim i As Integer
        For i = 0 To dts.Tables(0).Rows.Count - 1
            Try
                dts.Tables(0).Rows(i)("Rango") = Talonario.BuscarFiltrado(dts.Tables(0).Rows(i)("idTalonario").ToString(), "", "", "", "", "", "").Tables(0).Rows(0)("Rango").ToString()
                dts.Tables(0).Rows(i)("IdTipoTalonario") = Talonario.BuscarFiltrado(dts.Tables(0).Rows(i)("idTalonario").ToString(), "", "", "", "", "", "").Tables(0).Rows(0)("IdTipoTalonario").ToString()
                dts.Tables(0).Rows(i)("Talonario") = Talonario.BuscarFiltrado(dts.Tables(0).Rows(i)("idTalonario").ToString(), "", "", "", "", "", "").Tables(0).Rows(0)("DescripcionLetra").ToString()
                dts.Tables(0).Rows(i)("Operador") = Personal.ListarNombres(Int(dts.Tables(0).Rows(i)("Legajo").ToString()), "").Tables(0).Rows(0)("NombreApellido").ToString()
            Catch ex As Exception

            End Try
        Next
        Return dts
    End Function
    Public Function Modificar(ByVal idAsignacionesDeRemitos As String, ByVal FechaDeAlta As String, ByVal FechaDeBaja As String, ByVal IdTalonario As String, ByVal Legajo As String) As Boolean
        Return AsignacionesDeRemitos.Modificar(idAsignacionesDeRemitos, FechaDeAlta, FechaDeBaja, IdTalonario, Legajo)
    End Function
End Class
